function changelocation(adirect) {
    window.location.href = adirect;
}


function openChatClick(_this){
    var autoredirect = $("#autoredirect").val();
    var fromUserId = $("#checkLogin").val();
    var toUserId = $(_this).attr("data-id");
    if(fromUserId===toUserId){
        alert("不能和自己私信!");
        return;
    }
    window.location.href = "/home/chats/"+fromUserId+"/"+toUserId+"/?autoredirect="+autoredirect;
}

$(function () {
    $(".push_click").click(function(e){
        var checkLogin = $("#checkLogin").val();
        var autoredirect = $("#autoredirect").val();
        if(checkLogin == 0){
            alert("请登录之后再进行投票,谢谢!");
            window.location.href = "/home/login?autoredirect="+autoredirect;
            return;
        }
        var ajuId = $(this).parent().find("#ajuId").val();
        var clicks_n =  $("#clicks_v"+ajuId).val();
        $.ajax({
            type: "post",
            url: "/home/api/ac/joinuser/"+ajuId,
            cache: false,
            async: false,
            dataType: "json",
            success: function (result) {
                if(result.code !== 200){
                    alert(result.msg);
                }else{
                    alert(result.msg);
                    var thisclicks =  $("#clicks_"+ajuId);
                    thisclicks.val("给他投票("+(parseInt(clicks_n)+1)+")");
                    var clicks = $("#leiji_clicks").html();
                    $("#leiji_clicks").html(parseInt(clicks)+1);
                }
            }
        });
        // $.post("/home/api/ac/joinuser/"+ajuId,'', function (result) {
        //     if(result.code !== 200){
        //         alert(result.msg);
        //     }else{
        //         $(this).prop("value","给他投票("+(parseInt(clicks)+1)+")");
        //         var clicks = $("#leiji_clicks").html();
        //         $("#leiji_clicks").val(parseInt(clicks)+1);
        //         alert(result.msg);
        //     }
        // });
    });
});